package com.ynunicom.dc.dingdingcontractapp.tasklistener;

import com.ynunicom.dc.dingdingcontractapp.utils.SpringHelper;
import org.flowable.engine.TaskService;
import org.flowable.engine.delegate.TaskListener;
import org.flowable.task.service.delegate.DelegateTask;

import java.util.Map;

/**
 * @author: jinye.Bai
 * @date: 2020/6/5 17:08
 */
public class ManagerTaskStartListener implements TaskListener {
    private static final long serialVersionUID = -146094267759478088L;


    @Override
    public void notify(DelegateTask delegateTask) {
        TaskService taskService = SpringHelper.getTaskService();
        Map<String,Object> map = taskService.getVariables(delegateTask.getId());
        String isManagerOk = (String) map.get("isManagerOk");
        if (Boolean.parseBoolean(isManagerOk)){
            taskService.complete(delegateTask.getId());
        }
    }
}
